#append str to end of file
sub echo {
	my ($target, $string) = @_;
	system "echo $string >> $target";
}
#split by commas
sub tokenize {
	my @vals = split(/[ ]*,[ ]*/, $_[0]);
	chomp @vals;
	return @vals;
}
#clear a file
sub clear {
	system "cat /dev/null > $_[0]";
}
#write to log.txt
sub alog {
	clear("log.txt");
	echo("log.txt", $_[0]);
}
#get date in 20120416 format
#optional parameter adds days to it
sub date {
	my $offset = $_[0] ? $_[0]*86400 : 0;
	my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time+$offset);
	$mon = length($mon+1) == 1 ? "0" . ($mon+1) : $mon+1;
	$mday = length($mday) == 1 ? "0" . $mday : $mday;
	$year+=1900;
	return "$year$mon$mday"; 
}
#get it in 4/16/2012 date for the pdf file
sub pretty_date {
	my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
	$mon++;
	$year+=1900;
	return "$mon/$mday/$year"; 
}
1;
